import request from '/@/utils/request';

export function goodCatalogApi() {
	const view = (id: string) => {
		return request({
			url: `/management/goodscatalog/view/${id}`,
			method: 'GET',
		});
	};

	const create = (data: object) => {
		return request({
			url: '/management/goodscatalog/create',
			method: 'POST',
			data,
		});
	};

	const update = (data: object) => {
		return request({
			url: '/management/goodscatalog/update',
			method: 'put',
			data,
		});
	};

	const deleted = (data: object) => {
		return request({
			url: '/management/goodscatalog/delete',
			method: 'POST',
			data,
		});
	};

	const deletedById = (id: string) => {
		return request({
			url: `/management/goodscatalog/delete/${id}`,
			method: 'DELETE',
		});
	};

	const tree = () => {
		return request({
			url: '/management/goodscatalog/tree',
			method: 'get',
		});
	};

	const tree_choice = () => {
		return request({
			url: `/management/goodscatalog/tree?choice=1`,
			method: 'get',
		});
	};

	const updateRoot = (data: object) => {
		return request({
			url: '/management/goodscatalog/update/root',
			method: 'put',
			data,
		});
	};

	const search = (data: object) => {
		return request({
			url: '/management/goodscatalog/search',
			method: 'post',
			data,
		});
	};

	const all = () => {
		return request({
			url: '/management/goodscatalog/all',
			method: 'post',
		});
	};

	const used = (data: object) => {
		return request({
			url: '/management/goodscatalog/used',
			method: 'post',
			data,
		});
	};

	return { create, update, deleted, tree, tree_choice, view, deletedById, updateRoot, search, all, used };
}
